package DataModel.DesignRulesManager;

import DataModel.DesignRulesManager.CCommonUtils.EDesignRuleType;
import DataModel.LayoutManager.CRectangle;

public class CDesignRulesViolation {
	
	private CRectangle r1;
	private CRectangle r2;
	private EDesignRuleType rule;
	public CRectangle getR1() {
		return r1;
	}
	public void setR1(CRectangle r1) {
		this.r1 = r1;
	}
	public CRectangle getR2() {
		return r2;
	}
	public void setR2(CRectangle r2) {
		this.r2 = r2;
	}
	public EDesignRuleType getRule() {
		return rule;
	}
	public void setRule(EDesignRuleType rule) {
		this.rule = rule;
	}
	public CDesignRulesViolation(CRectangle r1, CRectangle r2, EDesignRuleType rule) {
		super();
		this.r1 = r1;
		this.r2 = r2;
		this.rule = rule;
	}
	
	public  void print() {
		System.out.println("Violation..."+rule);
		
		System.out.println("Layer: "+r1.getLayer() + "  ["+r1.getLeftEdge().getStartPoint().x+","+r1.getLeftEdge().getStartPoint().y+":"+r1.getRightEdge().getStartPoint().x+","+r1.getRightEdge().getStartPoint().y+"]");
		if (r2 != null && r1 != r2)
			System.out.println("Layer: "+r2.getLayer() + "  ["+r2.getLeftEdge().getStartPoint().x+","+r2.getLeftEdge().getStartPoint().y+":"+r2.getRightEdge().getStartPoint().x+","+r2.getRightEdge().getStartPoint().y+"]");
		System.out.println("-------------------");
	}
	@Override
	public String toString() {
		String str1 = new String("Violation..."+rule+" Layer: "+r1.getLayer() 
								+ "  ["+r1.getLeftEdge().getStartPoint().x+","+r1.getLeftEdge().getStartPoint().y
								+":"+r1.getRightEdge().getStartPoint().x+","+r1.getRightEdge().getStartPoint().y+"]");
		if (r2 != null && r1 != r2) {
			String str2 = new String (" Layer: "+r2.getLayer() + "  ["+r2.getLeftEdge().getStartPoint().x+","+r2.getLeftEdge().getStartPoint().y+":"+r2.getRightEdge().getStartPoint().x+","+r2.getRightEdge().getStartPoint().y+"]");
			str1 = str1.concat(str2);
		}
		return str1;
	}
}
